package Cn.Sarkar.MMS.Entities.Independent.Wallet

import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.hasOne
import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.IDataContext
import Cn.Sarkar.MMS.DataBaseDefinations.Independent.Wallet.Wallets
import Cn.Sarkar.Entities.Common.Additional.IDescription
import Cn.Sarkar.MMS.Entities.Additional.Description
import Cn.Sarkar.Entities.Common.BaseEntity
import Cn.Sarkar.MMS.Entities.Independent.Account
import Cn.Sarkar.Entities.MMS.Independent.IAccount
import Cn.Sarkar.Entities.MMS.Independent.Wallet.IChangeHistory
import Cn.Sarkar.Entities.MMS.Independent.Wallet.IMemberShipLevel
import Cn.Sarkar.Entities.MMS.Independent.Wallet.IWallet
import org.joda.time.DateTime
import java.util.*

class Wallet(DataContext: IDataContext) : BaseEntity(DataContext, Wallets), IWallet {
    var accountID by Wallets.AccountID
    override var account: IAccount by hasOne(Wallets.AccountID) { Account(it) }
    override var integral: Float by Wallets.Integral
    override var money: Float by Wallets.Money
    var memberShipLevelID by Wallets.MemberShipLevelID
    override var memberShipLevel: IMemberShipLevel by hasOne(Wallets.MemberShipLevelID) { MemberShipLevel(it) }
    override var supportLevelUpgrade: Boolean by Wallets.SupportLevelUpgrade
    override var levelUpgradedTime: DateTime by Wallets.LastUpdatedTime
    override var timeOutDaysIfUnUsed: Int by Wallets.TimeOutDaysIfUnUsed
    override var toNowTotalIntegralCount: Float by Wallets.ToNowTotalIntegralCount
    override var toNowTotalMoney: Float by Wallets.ToNowTotalMoney
    override var toNowUseCount: Int by Wallets.ToNowUseCount
    override var histories: MutableList<IChangeHistory> = LinkedList()
    var descriptionID by Wallets.DescriptionID
    override var description: IDescription by hasOne(Wallets.DescriptionID) { Description(it) }
    override var icCardID: String by Wallets.ICCardID
    override var magnetCardID: String by Wallets.MagnetCardID
    override var rFIDCardID: String by Wallets.RFIDCardID
    override var creditLevel: Int by Wallets.CreditLevel
}